package com.yazi.mxz.common.db.dao.impl;



import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.yazi.mxz.common.db.dao.LocalSaleDao;
import com.yazi.mxz.common.entity.beans.LocalSale;
import com.yazi.mxz.common.entity.beans.Store;

import com.myframework.smhj.hibernate.dao.BasicDao;

@Repository("localSaleDao")
public class LocalSaleDaoImpl extends BasicDao<LocalSale> implements LocalSaleDao {

	
	public LocalSaleDaoImpl() {
		super(LocalSale.class);
		
	}

	@Override
	public Criteria getExample(LocalSale sale, String searchWord) {
		Criteria c = super.getExample(sale, searchWord);
		
		// 关联对象条件
		if (null != sale) {
			// 店铺
			Store store = sale.getStore();
			if (null != store) {
				// 店铺ID
				if (null != store.getStoreId()) {
					c.add(Restrictions.eq("store.storeId", store.getStoreId()));
				} else {
					//...店铺其它条件
				}
			}
			// ...其它关联对象条件
		}
		
		// ...关键字searchWord条件
		return c;
	}
}
